package net.API.IssueLemon.display;

import net.API.IssueLemon.ThreadMain.ThreadMain;
import net.API.IssueLemon.ThreadMain.logger;
import net.API.IssueLemon.Main;

import javax.swing.*;
import java.awt.*;

public class Display {
    public static String TITLE = "window";
    public static int X = 854;
    public static int Y = 480;
    public static JFrame frame = new JFrame();
    public static JLabel root = new JLabel();
    public static Graphics g;

    private static void thread_a(){
        Thread thread = new Thread(){
            @Override
            public void run(){
                logger.info("thread/info", "Registration window...");
                logger.warning("thread/warning", "Note that there may be an error here, but this is not an error, it is a warning!");
            }
        };
        Thread thread1 = new Thread(){
            @Override
            public void run(){
                frame.setTitle(TITLE);
                frame.setLayout(null);
                root.setLayout(new FlowLayout());
                Main.show();
                frame.setSize(X, Y);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        };
        thread.run();
        thread1.run();
    }

    public void LocationRelativeTo(){
        frame.setLocationRelativeTo(null);
    }

    public void show(){
        frame.setVisible(true);
    }

    public Display(String title, int x, int y){
        TITLE = title;
        X = x;
        Y = y;
        logger.info("thread/info", "Now use multithreading to create windows...");
        thread_a();
        logger.info("thread/info", "Creation completed!");
    }
}
